<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.longtop.com/intelliweb" prefix="e"%>
<%@page isELIgnored="false"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Insert title here</title>
	</head>
	<e:View id="view">
	    <script type="text/javascript">SkinUtil.getSkin();</script>
	    <script type="text/javascript">SkinUtil.getModuleSkin();</script>
	    
		<div id="Invisual Controls" style="min-height: 40px; background-color: LemonChiffon;" >
			<e:Dataset id="Dataset_User" datasetDefinition="DatasetDefinition_sys.dsd" datasetRef="dataset_user" pageSize="10" 
				loadDataCommand="Command_Load" allowMultiSelect="false">
				<e:Field name="userId" dataType="string" label="用户Id" maxLength="32"  required="true"/>
				<e:Field name="userName" dataType="string" label="用户姓名" maxLength="200"  required="true"/>
				<e:Field name="loginName" dataType="string" label="登录名" maxLength="60"  required="true"/>
				<e:Field name="password" dataType="string" label="密码" maxLength="32"  required="true"/>
				<e:Field name="orgId" dataType="string" label="所属部门" maxLength="32"  required="true" />
				<e:Field name="roleId" dataType="string" label="角色" maxLength="32"  required="true"/>
				<e:Field name="status" dataType="string" label="状态" maxLength="1"  required="true" dropDown="ListDropDown_Status"/>
				<e:Field name="sortNo" dataType="integer" label="用户排序号" maxLength="6"  required="true"/>
				<e:Field name="remark" dataType="string" label="remark" maxLength="200"  />
				<e:Field name="orgName" dataType="string" label="部门名称" maxLength="100" required="true"/>
				<e:Field name="duty" dataType="string" label="职务" maxLength="32" dropDown="ListDropDown__USER_DUTY" required="true"/>
				<e:Field name="sex" dataType="string" label="性别" maxLength="1" dropDown="ListDropDown_sex" required="true"/>
				<e:Field name="cardType" dataType="string" label="证件类型" maxLength="32" dropDown="ListDropDown__USER_CARD_TYPE" required="true"/>
				<e:Field name="cardNo" dataType="string" label="证件号码" maxLength="32" required="true"/>
				<e:Field name="isVirtual" dataType="string" label="是否虚拟柜员" maxLength="1" dropDown="ListDropDown_isVirtual" defaultValue="0"/>				
			</e:Dataset>
			<e:Dataset id="Dataset_Role" datasetDefinition="DatasetDefinition_sys.dsd" datasetRef="dataset_role" pageSize="-1">
				<e:Field name="roleId" dataType="string" label="角色编号" maxLength="32" />
				<e:Field name="roleName" dataType="string" label="角色名称" maxLength="60" />
				<e:Field name="sortNo" dataType="integer" label="sortNo" maxLength="4" />
				<e:Field name="remark" dataType="string" label="remark" maxLength="200" />
			</e:Dataset>
			
			<e:Command id="Command_Save" action="com.longtop.framework.sys.user.web.UserEditAction" method="saveUser" >
				<e:DatasetInfo name="DatasetInfo1" alwayRefreshClient="true" dataset="Dataset_User"></e:DatasetInfo>
			</e:Command>
			<!-- 确定MAX用户ID： -->
			<e:Command id="Command_queryMaxUserId" action="com.longtop.framework.sys.user.web.UserEditAction" method="queryMaxUserId" >
				<e:Parameter name="userIdType" value=""></e:Parameter>
				<e:Parameter name="resultUserId" value=""></e:Parameter>
			</e:Command>			
			
			<e:DataDropDown id="DataDropDown_Role" dataset="Dataset_Role" visibleFields="roleId,roleName"
					writeFields="" codeField="roleId" textField="roleName" autoDropDown="true" fixed="true">
			</e:DataDropDown>
			<e:LookupDropDown id="LookupDropDown_Org" path="/jsp/framework/sys/org/orgDropdown.jsp"	windowWidth="600" windowHeight="400" 
					autoDropDown="true" fixed="true" onSelect="LookupDropDown_Org_onSelect(dropdown,iframe,text)" windowCaption="选择部门">
			</e:LookupDropDown>
			<e:ListDropDown id="ListDropDown_Status" fixed="true" autoDropDown="true">
				<e:ListDropDownItem name="ListDropDownItem1" label="锁定" value="0"></e:ListDropDownItem>
				<e:ListDropDownItem name="ListDropDownItem2" label="激活" value="1" selected="true"></e:ListDropDownItem>
			</e:ListDropDown>
			
			<e:ListDropDown id="ListDropDown__USER_DUTY" fixed="true" autoDropDown="true"></e:ListDropDown>
			<e:ListDropDown id="ListDropDown__USER_CARD_TYPE" fixed="true" autoDropDown="true"></e:ListDropDown>
			
			<e:ListDropDown id="ListDropDown_isVirtual" fixed="true" autoDropDown="true">
				<e:ListDropDownItem name="ListDropDownItem1" label="否" value="0"></e:ListDropDownItem>
				<e:ListDropDownItem name="ListDropDownItem2" label="是" value="1"></e:ListDropDownItem>
			</e:ListDropDown>
			<e:ListDropDown id="ListDropDown_sex" fixed="true" autoDropDown="true">
				<e:ListDropDownItem name="ListDropDownItem1" label="女" value="0"></e:ListDropDownItem>
				<e:ListDropDownItem name="ListDropDownItem2" label="男" value="1"></e:ListDropDownItem>
			</e:ListDropDown>
			
			<!-- 用户ID的选择 -->
			<e:ListDropDown id="ListDropDown_userId" fixed="true" onAfterSelect="ListDropDown_userId_onAfterSelect()">
				<e:ListDropDownItem name="ListDropDownItem1" label="手工输入" value="0"></e:ListDropDownItem>
			</e:ListDropDown>			
			
			<e:DatePicker id="DatePicker_Date" autoDropDown="false" fixed="true" autoShowDropDownButton="true" showType="date"></e:DatePicker>
		</div>
	
		<body>
			<e:Page id="ePage" action="com.longtop.framework.sys.user.web.UserEditAction" style="min-height: 80px; width: 100%; height: 100%;" onAfterLoadPage="ePage_onAfterLoadPage()">
				<table style="width: 100%; height: 100%;" border="0" cellpadding="2" cellspacing="2" width="100%" align="center">
					<tr>
						<td valign="top">
							<e:Panel id="Panel_Result" style="width: 100%; height: 100%" captionStyle="color:#888888" caption="用户编辑" captionIcon="/images/list_win.gif">
								<table style="text-align: left; width: 80%;" border="0" cellpadding="3" cellspacing="3" align="center">
									<tr align="center">
										<td align="center" nowrap="nowrap" colspan="6">
											<e:Button id="Button_Save" caption="保存" style="width: 70px; height: 22px" onClick="Button_Save_onClick()" icon="/images/submit.gif"></e:Button>&nbsp;&nbsp;
											<e:Button id="Button_Back" caption="返回" style="width: 70px; height: 22px" onClick="Button_Back_onClick()" icon="/images/undo.gif"></e:Button>
										</td>
									</tr>
									<tr align="center">
										<td nowrap="nowrap" height="20" align="right">所属部门:</td>
										<td align="left">
											<e:Text id="Text_orgName" dataset="Dataset_User" field="orgName" editorType="text" style="width: 160px" dropDown="LookupDropDown_Org"></e:Text>
										</td>
										<td nowrap="nowrap" height="20" align="right">用户ID:</td>
										<td align="left">
											<e:Text id="Text_id" dataset="Dataset_User" field="userId" editorType="text" style="width: 160px" dropDown="ListDropDown_userId"></e:Text>
										</td>		
										<td  nowrap="nowrap" height="20" align="right">用户排序号:</td>
										<td align="left">
											<e:Text id="Text_sortNo" dataset="Dataset_User" field="sortNo" editorType="text" style="width: 160px"></e:Text>
										</td>																			
									</tr>
									<tr align="center">
										<td nowrap="nowrap" height="20" align="right">用户姓名:</td>
										<td align="left">
											<e:Text id="Text_name" dataset="Dataset_User" field="userName" editorType="text" style="width: 160px"></e:Text>
										</td>
										<td nowrap="nowrap" height="20" align="right">用户性别:</td>
										<td align="left">
											<e:Text id="Text_sex" dataset="Dataset_User" field="sex" editorType="text" style="width: 160px" ></e:Text>
										</td>	
										<td nowrap="nowrap" height="20" align="right">用户状态:</td>
										<td align="left">
											<e:Text id="Text_status" dataset="Dataset_User" field="status" editorType="text" style="width: 160px" ></e:Text>
										</td>																																	
									</tr>
									<tr>
										<td nowrap="nowrap" height="20" align="right">登陆名:</td>
										<td align="left">
											<e:Text id="Text_loginName"	dataset="Dataset_User" field="loginName" editorType="text" style="width: 160px"></e:Text>
										</td>
										<td  nowrap="nowrap" height="20" align="right">用户密码:</td>
										<td align="left">
											<e:Text id="Text_password" dataset="Dataset_User" field="password" editorType="password" style="width: 160px"></e:Text>
										</td>	
										<td nowrap="nowrap" height="20" align="right">所属角色:</td>
										<td align="left">
											<e:Text id="Text_roleId" dataset="Dataset_User" field="roleId" editorType="text" style="width: 160px" dropDown="DataDropDown_Role"></e:Text>
										</td>																																										
									</tr>
									<tr>
										<td nowrap="nowrap" height="20" align="right">证件类型:</td>
										<td align="left">
											<e:Text id="Text_cardType"	dataset="Dataset_User" field="cardType" editorType="text" style="width: 160px"></e:Text>
										</td>
										<td  nowrap="nowrap" height="20" align="right">证件号码:</td>
										<td align="left">
											<e:Text id="Text_cardNo" dataset="Dataset_User" field="cardNo" editorType="text" style="width: 160px"></e:Text>
										</td>
										<td nowrap="nowrap" height="20" align="right">职务:</td>
										<td align="left">
											<e:Text id="Text_duty" dataset="Dataset_User" field="duty" editorType="text" style="width: 160px"></e:Text>
										</td>																						
									</tr>														
									<tr>
									<!--  
										<td nowrap="nowrap" height="20" align="right">是否虚拟柜员:</td>
										<td align="left">
											<e:Text id="Text_isVirtual" dataset="Dataset_User" field="isVirtual" editorType="text" style="width: 160px"></e:Text>
										</td>
									-->		
										<td  nowrap="nowrap" height="20" align="right">备注:</td>
										<td align="left" colspan="5">
											<e:Text id="Text_remark" dataset="Dataset_User" field="remark" editorType="textArea" style="width: 100%; height: 80px;"></e:Text>
										</td>
									</tr>
									<tr>
										<td align="left" colspan="6">
											<font color="blue"> *友情提示：用户ID根据所属部门自动生成，也支持手工输入。</font>
										</td>
									</tr>
								</table>
							</e:Panel>		
						</td>
					</tr>
			    </table>
			</e:Page>
		</body>
	</e:View>
</html>

<script type="text/javascript">
	
	//init
	function ePage_onAfterLoadPage(){
		var flag = "${param.doflag}";
		if(flag == "insert"){
			Dataset_User.insertRecord();
			Dataset_User.setValue("status","1");
			Dataset_User.setValue("cardType","0");	
			Dataset_User.setValue("isVirtual","0");	
		}else {
			$J("Text_id").setReadOnly("true");
		}
		
	}
	
	//员工USERID的选择确定：
	function ListDropDown_userId_onAfterSelect(dropdown,item,text){
		var selectValue = item.getValue();
		if(selectValue == '0'){
			dropdown.fixed = false;
			$J("Text_id").setValue("");
			$J("Text_sortNo").setValue("");
		}else {
		}
	}
	
	//返回
	function Button_Back_onClick(){
		var tabName = "<%=request.getParameter("openerTabName") %>";
		returnToParentTab(tabName,true);
	}
	
	//保存
	function Button_Save_onClick(){
		var record = Dataset_User.getCurrentRecord();
		if(record){
			Command_Save.execute();
		}else{
			MsgBox.showWarnMsg("没有需要保存的数据");
		}
	}
	
	//选择部门
	function LookupDropDown_Org_onSelect(dropdown,iframe,text){
		var dataset = $J(iframe.Dataset_Org);
		var node = $J(iframe.DataTree_Org).getCurrentNode();
		var recordUser = Dataset_User.getCurrentRecord();
	    var record = dataset.getCurrentRecord();
	    if(typeof record != "undefined" && record != null){   	
	   		recordUser.setValue("orgId",record.getValue("orgId"));
	   		recordUser.setValue("orgName",record.getValue("orgName"));
	    }
	    
		var flag = "${param.doflag}";
		if(flag == "insert"){//新增状态下：
			bulidUserId();	//自动生产员工ID
		}
	}
	
    //自动生产员工ID	
	function bulidUserId(){
	   	$J("ListDropDown_userId").fixed = true;
		Command_queryMaxUserId.parameters.setValue("userOrgId",Dataset_User.getValue("orgId"));
		Command_queryMaxUserId.execute();
		//设定返回的结果USERID值：
		var resultUserId = Command_queryMaxUserId.parameters.getValue("resultUserId");
		$J("Text_id").setValue(resultUserId);
		$J("Text_sortNo").setValue(resultUserId);		
	}
	
</script>